<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>类继承</title>
  </head>
  <body>
    <script>
      // 父类
      class Phone {
        // 构造方法
        constructor(brand, price) {
          this.brand = brand;
          this.prcie = price;
        }
        // 父类的成员属性
        call() {
          console.log("我可以打电话");
        }
      }
      // 子类
      class SmartPhone extends Phone {
        // 构造方法
        constructor(brand, price, color, size) {
          super(brand, price); // 父类的构造方法
          // 等同于 Phone.call(this,brand,price)
          this.color = color;
          this.size = size;
        }

        photo() {
          console.log("拍照");
        }
        playgame() {
          console.log("玩游戏");
        }
      }

      // 实例化子类
      const xiaomi = new SmartPhone("小米", 1999, "白色", 5.5);
      console.log(xiaomi);
      xiaomi.call();
      xiaomi.photo();
    </script>
  </body>
</html>
